﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntitiesLayer;
using System.Transactions;
using System.Data.SqlClient;
using System.Data;
using DAL.Repositories;
using DAL.AbstractRepositories;

namespace DAL.Repositorios
{
    public class RepositoryRelacionMPEjercicio : AbstractRelationRepository
    {

        protected void IERelacion( long idEjercicio ,long idMusculo, string SP){
            SqlCommand cmd = new SqlCommand();
            cmd.Parameters.Add(new SqlParameter("@pIdEjer", idEjercicio));
            cmd.Parameters.Add(new SqlParameter("@pIdMusc", idMusculo));
            DBAccess.ExecuteSPNonQuery(ref cmd, SP);
        }

        protected override void ConsultaAsignar(long idEjercicio, long idMusculo)
        {
            IERelacion(idEjercicio, idMusculo, "PaAsignarMusculoPXEjercicio");
        }

        protected override void ConsultaRemover(long idEjercicio, long idMusculo)
        {
            IERelacion(idEjercicio, idMusculo, "PaEliminarMusculosPXEjercicio");
        }

        public override void RemoveAllFromKey(long id)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Parameters.Add(new SqlParameter("@IdEjercicio", id));
            DBAccess.ExecuteSPNonQuery(ref cmd, "PaEliminarTodosMusculosP");
            
        }

        public override void RemoveAllFromRelated(long key)
        {
            throw new NotImplementedException();
        }
    }
}
